package lab02.test21;

import java.util.Scanner;

/**
 * Created by 123 on 2017/10/30.
 */
public class Test21 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();//从键盘输入一个字符串
        double times;//某个字符出现的次数

        int[] str1 = new int[str.length()];

        for (int i = 0; i < str.length(); i++) {
            str1[i] = (int) str.charAt(i);
            System.out.println(str1[i]);
        }

        for (int i = 0; i < str1.length; i++) {
            times = 0;

            for (int j = 0; j < str1.length; j++) {
                if (str1[j] == str1[i]) {
                    times = times + 1;
                }
            }

                    System.out.println("字符" + str.charAt(i) + "频率为" + times / str.length());

            }
        }




 /*
     char[] str1=new char[str.length()];//创建一个字符型数组用来存储

        char strcompara[] = new char[str.length()];//存储已经比较过的字符

        double times=0;//某个字符出现的次数

        for (int i = 0; i <str.length(); i++) {
            str1[i]=str.charAt(i);//将字符串的每一个字符依次存入数组中
        }

        for (int i = 0; i <str.length(); i++) {
            for (int j = 0; j < str1.length-1; j++) {
                char tmp=str1[j];
              if (tmp==str.charAt(i)){
                  times=times+1;
              }
            }
            System.out.println("字符"+str.charAt(i)+"频率为"+times/str.length());

        }
*/

    }

